
const searchFormList = [
  { label: '', width: '130px', value: 'btnOperation', type: 'slot' },
	{ label: '关键词', value: 'query', type: 'input', width: '200px' },
  { label: '隶属班级', value: 'starid', type: 'select', width: '200px', option: 'sysStar', filterable: true,  clearable: true},
	{ label: '', width: '200px', value: 'btnSearch', type: 'slot' }
];

const tables = [ // 表格数据
  { label: '记录ID', value: 'id', sort:'custom', width:100},
  { label: '帖子标题', value: 'title'},
  { label: '帖子分类', value: 'catid', sort:'custom', type: 'slot'},
  { label: '隶属班级', value: 'starid', sort:'custom', type: 'slot'},
  { label: '是否常见问题', value: 'istop', type: 'slot', width:100},
  { label: '跳转链接', value: 'link'},
  { label: '浏览量', value: 'clicks', width:80},
  { label: '状态', value: 'status',sort:'custom', type: 'slot', width:100},
  { label: '发帖时间', value: 'addtime'},
  { label: '更新时间', value: 'stime'}
];

const fieldList = [ // 新增弹出数据
  { label: '标题', value: 'title', type: 'input', width: '460px', className:'block'},
  { label: '跳转链接', value: 'link', type: 'input', width: '460px', className:'block'},
  { label: '隶属班级', value: 'starid', type:'select', width: '200px', option: 'sysStar', filterable: true, className:''},
  { label: '审核状态', value: 'status', type:'select', width: '180px', labelWidth:"80px", option: 'checkStatus', filterable: true, className:''},
  { label: '是否常见问题', value: 'istop', type:'select', width: '200px', labelWidth:"100px", option: 'yesOrNo', filterable: true, className:''},
  { label: '帖子分类', value: 'catid', type:'select', attchsField:"tags",  width: '840px', option: 'gcHCenterCategory', className:''},
  { label: '帖子内容', value: 'data', type:'editor', width: '840px', ueditorStyle:{width:'720px', height:'240px'}, className:''},
];

const rules = {
	title: [{ required: true, message: '请输入标题', trigger: 'change' }],
	status: [{ required: true, message: '请设置状态', trigger: 'change' }],
  content: [{ required: true, message: '请编辑帖子内容', trigger: 'change' }]
};

const fieldData = (data)=>{
  var dataset = {};
  for (var idx = 0; idx < fieldList.length; idx++) {
    var ckey  = fieldList[idx].value;
    dataset[ckey] = (data)? data[ckey]:'';
  }
  dataset.id = (data && data.id)? data.id:0;
  return dataset;
}

export default {
  searchFormList,tables,fieldList,fieldData,rules
};